package com.sky.mapper;

import com.sky.autofill.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    /**
     * 吃得像套餐
     *
     * @param name       名称
     * @param status     地位
     * @param categoryId 类别id
     * @return {@link List}<{@link Setmeal}>
     */
    List<Setmeal> getLikeSetmeal(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * 添加套餐
     *
     * @param meal 一餐
     */
    @AutoFill(OperationType.INSERT)
    void addSetmeal(Setmeal meal);

    /**
     * 吃套餐
     *
     * @param id id
     * @return {@link Setmeal}
     */
    @Select("select * from setmeal where id=#{id}")
    Setmeal getSetmeal(Long id);

    /**
     * 删除套餐
     *
     * @param ids ids
     */
    void deleteSetmeal(List<Long> ids);

    /**
     * 套餐
     *
     * @param meal 一餐
     */
    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal meal);

    /**
     * 获取套餐数量
     *
     * @param name 名称
     * @return {@link Integer}
     */
    @Select("select count(*) from setmeal where name =#{name}")
    Integer getSetmealCount(String name);

    @Select("select count(*) from setmeal where name = #{name} and id != #{id}")
    Integer getSetmealCounts(String name, Long id);

    Setmeal selectSetmealById(Long setmealId);
}
